package cc.linker.steplink.crm.task;

import cc.linker.steplink.crm.commons.lock.RedisLock;
import cc.linker.steplink.crm.merchant.dao.WxDao;
import cc.linker.steplink.crm.merchant.pojo.menu.PublicMenuPo;
import cc.linker.steplink.crm.merchant.service.PublicMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @Author: CKQ
 * @DateTime: 2020/8/27 16:17
 * @Description: TODO
 */
@Slf4j
@Component
@Async
public class  CustomerTagTask {

    @Autowired
    private PublicMenuService publicMenuService;
    @Autowired
    private WxDao wxDao;

    @RedisLock("CustomerTagTask")
    @Scheduled(cron = "0 30 2 * * ?")
    public void runCustomerTagTask() {
        List<Map<String, Object>> tokenList = wxDao.getWxPublistList();
        this.publicMenuService.runCalculateGroupCustomerTag(tokenList);
        this.publicMenuService.runMakeCustomerTag(tokenList);
    }
}
